Skip to content

Comments

feat(wrangler): add Cloudflare Wrangler CLI support#138

Open
sujito00 wants to merge 4 commits intortk-ai:masterfrom
Balneario-de-Cofrentes:feat/wrangler-cmd
Open

feat(wrangler): add Cloudflare Wrangler CLI support#138
sujito00 wants to merge 4 commits intortk-ai:masterfrom
Balneario-de-Cofrentes:feat/wrangler-cmd

Conversation

@sujito00
Copy link

Summary

Adds rtk wrangler command for Cloudflare Workers CLI with compact, token-optimized output.

Subcommands

rtk wrangler deploy

Compresses verbose deploy output into a compact status line:

Before (raw wrangler output ~15 lines):

 ⛅️ wrangler 4.14.4 (update available 4.15.0)
-------------------------------------------------------
▲ [WARNING] Your worker has access to the following bindings
  - KV Namespaces: MY_KV
  - D1 Databases: MY_DB
Total Upload: 123.45 KiB / gzip: 34.56 KiB
Worker Startup Time: 5 ms
Uploaded api-worker (2.34 sec)
Deployed api-worker triggers (0.67 sec)
  https://api-worker.username.workers.dev
  https://api.example.com
Current Version ID: xyz789abc012

After (rtk output ~5 lines, ~70% reduction):

✓ api-worker deployed (2.34 sec) 123.45 KiB/34.56 KiB gzip
  https://api-worker.username.workers.dev
  https://api.example.com
  version: xyz789abc012
  ⚠ 1 warning (bindings: KV, D1)

rtk wrangler pages

Compact Cloudflare Pages deploy output:

✓ 24 files uploaded (2.34 sec)
  https://abc123.my-pages.pages.dev

rtk wrangler dev

Passthrough with inherited I/O (interactive dev server).

Other subcommands

Transparent passthrough for any unrecognized wrangler subcommand.

Features

  • Strips wrangler banner (⛅️ header + dashes)
  • Extracts and summarizes binding warnings (KV, D1, R2, DO, AI, Queue, Vectorize, Hyperdrive, etc.)
  • Deduplicates binding types in warning summary
  • Preserves error output and exit codes for CI/CD
  • Handles ANSI color code stripping
  • Edge cases: missing gzip size, no URLs, empty output, schedule triggers

Tests

15 unit tests covering:

  • Basic deploy with URL + size + version
  • Deploy with warnings and binding type extraction
  • Deploy with schedule triggers
  • Multiple warnings with binding dedup
  • Error output handling
  • ANSI code stripping
  • Pages deploy (success + error + edge cases)
  • Field extraction for both deploy types
  • Empty output fallback
test result: ok. 15 passed; 0 failed; 0 ignored; 0 measured

Full test suite passes (353 tests including existing):

test result: ok. 353 passed; 0 failed; 0 ignored; 0 measured

Motivation

Cloudflare Workers is a major deployment target. The verbose deploy output wastes significant tokens in LLM coding sessions, especially during iterative deploy-test cycles.

@pszymkowiak
Copy link
Collaborator

Nice work — this is a clean, well-structured PR. Good architecture with Clap subcommands, proper exit code propagation, error handling when wrangler isn't installed, and interactive
passthrough for dev. The 15 tests cover the important cases well.

Two things to fix before merge:

  1. cargo fmt fails

A few spots in wrangler_cmd.rs need formatting. Running cargo fmt should fix them automatically.

  1. Dead code in parse_deploy_output

The known bindings detection block (~line 145-163) parses binding types but does nothing with them:

if known_bindings.iter().any(|b| binding_type.trim() == *b) {
// These get summarized in the warning line
}

This is a no-op — the actual work is done by extract_binding_types() called separately in filter_deploy_output. This block can be removed.

A rebase on current master will also be needed since the branch is a few versions behind. Once these are addressed, this is good to merge.

@sujito00
Copy link
Author

Thanks for the review feedback! Changes addressed:

  • Rebased on master (v0.20.1) — resolved merge conflicts with hook-audit additions
  • cargo fmt — verified clean
  • Dead code removed — the known_bindings no-op block is gone
  • CI validate-docs fix — updated version refs (0.18→0.20.1) in README, CLAUDE.md, ARCHITECTURE.md; module count 47→49 (added wrangler_cmd + hook_audit_cmd entries)
  • All tests pass (15/15 wrangler tests + full suite)
  • Clippy clean — zero warnings

Ready for re-review. Thanks! 🙏

Add wrangler command with compact output for Cloudflare Workers deployments:

- `rtk wrangler deploy`: Compresses verbose deploy output to single status
  line with worker name, size, URLs, version, and warning summary
- `rtk wrangler pages`: Compact pages deploy (file count + URL)
- `rtk wrangler dev`: Passthrough with inherited I/O for interactive use
- Other subcommands: transparent passthrough

Features:
- Strips wrangler banner and decorative output
- Extracts and summarizes binding warnings (KV, D1, R2, DO, AI, etc.)
- Deduplicates binding types in warning summary
- Preserves error output and exit codes for CI/CD
- Handles ANSI color code stripping
- Handles edge cases: missing gzip size, no URLs, empty output

Tests: 15 unit tests covering deploy, pages, errors, bindings, ANSI
stripping, edge cases, and field extraction.
@pszymkowiak
Copy link
Collaborator

Review: PR #138

Thanks for the Wrangler code — the deploy/pages/dev/passthrough architecture is clean, 15 tests cover the key cases well, and the Clap subcommand structure is exactly right.

However, the PR includes unrelated deletions that would cause regressions on master:

Deletion Impact
wc_cmd.rs removed (401 lines) Breaks rtk wc (shipped in v0.22.0)
git commit messages: Vec<String>String Breaks multi-paragraph commits (-m "line1" -m "line2")
filter_markdown_body removed from gh_cmd Regression: PR bodies no longer filtered
grep -n flag removed Regression on existing grep behavior
process::exit removed in git branch Exit code not propagated on failure
263 lines of tests deleted (git branch, gh markdown) Lost coverage

This likely happened during rebase conflict resolution — the merge deleted existing code instead of preserving it.

Fix: Rebase cleanly on current master, keeping only the Wrangler additions (wrangler_cmd.rs + main.rs routing). The existing files (wc_cmd.rs, git.rs, gh_cmd.rs, grep_cmd.rs, playwright_cmd.rs) should not be modified.

The Wrangler code itself is solid — happy to merge once the unrelated changes are reverted!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants